#include "MeshBuffer.h"
#include "Common/CommonTypes.h"
#include "RenderSystem.h"
#include "HardwareResourceManager.h"
#include "Scene/Engine.h"
#include "VertexBuffer.h"
#include "IndexBuffer.h"

CMeshBuffer::CMeshBuffer( CVertexBuffer* pVertexBuffer, CIndexBuffer* pIndexBuffer )
{
	m_pVertexBuffer = pVertexBuffer;
	m_pIndexBuffer = pIndexBuffer;
	m_dwVertexOffset = m_dwIndexOffset = 0;
}

CMeshBuffer::~CMeshBuffer()
{
	m_pVertexBuffer = NULL;
	m_pIndexBuffer = NULL;
}

void CMeshBuffer::Render(CRenderSystem* pRenderer)
{
	pRenderer->DrawMesh(this);
}

void CMeshBuffer::Release()
{
	CHardwareResourceManager* pHWResMgr = GetEngine()->GetHwResMgr();

	pHWResMgr->ReleaseResource(m_pVertexBuffer);
	pHWResMgr->ReleaseResource(m_pIndexBuffer);
}

